package com.corpdata.activiti.controller;

import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("test/")
public class TestController {
	
	@Autowired
	private RuntimeService runtimeService;
	
	@RequestMapping("start")
	public String testStart(){
		Map<String, Object> variables = new HashMap<String, Object>();
		variables.put("employeeName", "Kermit");
		variables.put("numberOfDays", new Integer(4));
		variables.put("vacationMotivation", "I'm really tired!");
		ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("vacationRequest", variables);
		// Verify that we started a new process instance
		String rs = "Number of process instances: " + runtimeService.createProcessInstanceQuery().count();
		return rs;
		//Log.info("Number of process instances: " + runtimeService.createProcessInstanceQuery().count());
	}
}
